package com.bingbing.back.service.Impl;

import com.bingbing.back.dto.SchoolMajorScoreDto;
import com.bingbing.back.mapper.SchoolMajorScoreMapper;
import com.bingbing.back.po.SchoolMajorScore;
import com.bingbing.back.service.SchoolMajorScoreService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SchoolMajorScoreServiceImpl implements SchoolMajorScoreService {
    @Resource
    private SchoolMajorScoreMapper schoolMajorScoreMapper;

    @Override
    public List<String> showBatch(int schoolId, int admYear) {
        return schoolMajorScoreMapper.showBatch(schoolId, admYear);
    }

    @Override
    public List<SchoolMajorScoreDto> showMajorScore(SchoolMajorScore schoolMajorScore) {
        List<SchoolMajorScoreDto> list = schoolMajorScoreMapper.showMajorScore(schoolMajorScore);
        list.forEach(s->{
            String str = "";
            if(s.getMajorLoScore() == null) str += "-";
            else str += s.getMajorLoScore().toString();
            str += "/";
            if(s.getMajorLoRank() == null) str += "-";
            else str += s.getMajorLoRank().toString();
            s.setScoreAndRank(str);
        });
        return list;
    }
}
